#!/usr/bin/env python3

import sys

sys.path.append("../lib")

from spread_sheet import Spreadsheet
from rich import print as rprint

FILES = [
    "玉溪-20241127-产业领域项目三张清单/20241127-汇总-附件3：投资完成滞后项目清单（玉溪）.xlsx",
    "玉溪-20241205-产业领域项目三张清单/20241205-汇总-附件3：投资完成滞后项目清单（玉溪）.xlsx",
    "玉溪-20241212-产业领域项目三张清单/20241212-汇总-附件3：投资完成滞后项目清单（玉溪）.xlsx",
    "玉溪-20241218-产业领域项目三张清单/20241218-汇总-附件3：投资完成滞后项目清单（玉溪）.xlsx",
]


def get_last_two():
    return FILES[-2:]


def diff_all(range_str):
    changes = []
    for i in range(len(FILES) - 1):
        old_file = FILES[i]
        new_file = FILES[i + 1]
        rprint("Diff", old_file, "VS", new_file)
        val = diff_two(old_file, new_file, range_str)
        changes.append(*val)
    return changes


def diff_two(old_file, new_file, range_str):
    old_spreadsheet = Spreadsheet(old_file, data_only=True)
    new_spreadsheet = Spreadsheet(new_file, data_only=True)

    single_mod_cells = old_spreadsheet.dry_diff(new_spreadsheet, range_str=range_str)
    rprint("Change", single_mod_cells)
    return single_mod_cells
    print("-------------------------------------")


def investment_plus(val):
    print(f'经过努力新增完成投资{int(round(val[2],0))}万元，较上周增加{int(round(val[2]-val[1], 0))}万元。')


def main():
    # old_file, new_file = get_last_two()
    # vals = diff_two(old_file, new_file, "AC7:AC7")

    # investment_plus(vals[0])

    changes = diff_all('AC7:AC7')
    print('Changes', changes)

    pass


if __name__ == "__main__":
    main()
